/* mntree/include/mntree/mntree.h
 * 
 * This file is part of mntree. 
 * 
 * mntree is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * mntree is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with mntree. If not, see <https://www.gnu.org/licenses/>
 */ 





#ifndef __MNTREE_MNTREE_H
#define __MNTREE_MNTREE_H

/* 
 * mntree, tree with multiple nodes that can be greater than 2.
 * of course that these nodes have sorted, and we can find in it
 * quickly. */


#include <mntree/sys.h>


struct mntree_node {
	int 			nnodes;

	struct mntree_node 	*middle, 
				*parent, 
				*next_bro, 
				*prev_bro, 
				*leftmost, 
				*rightmost;

	int 			nmid;

	/* data */

	int 			value;
	void 			*payload;
};


struct mntree_node *mntree_init_node(struct mntree_node *parent, struct mntree_node *n);
struct mntree_node *mntree_init(struct mntree_node *parent, struct mntree_node *n);
struct mntree_node *mntree_link(struct mntree_node *parent, struct mntree_node *n);
struct mntree_node *mntree_find(struct mntree_node *parent, int value);
int mntree_each(struct mntree_node *node, int (* callback) (struct mntree_node *));

#endif

